// 简单约瑟夫环
#include <iostream>
#include <deque>
using namespace std;
void func(deque<int>&, int);
int main(){
    int n;
    int m;
    cin>>n>>m;
    deque<int> dq;
    for(int i = 1; i <= n; i++)
        dq.push_back(i);
    func(dq, m);
    return 0;
}
void func(deque<int>& dq, int m){
    while(!dq.empty()) {
        for(int i = 0; i < m-1; i++) {
            dq.push_back(dq.front());
            dq.pop_front();
        }
        cout << dq.front() << " ";
        dq.pop_front();
    }
    cout << endl;
}